import { BaseService, Service } from '../../../utils/request';
@Service('app/user')
export default class extends BaseService {
	// 密码登录
	login({ phone = '', password = '', code = '', captchaId = '', type = 1 }) {
		return this.request({
			url: '/login',
			method: 'POST',
			data: {
				phone,
				password,
				code,
				captchaId,
				target: 1,
				type
			}
		});
	}

	// 验证码登录
	smsLogin({ phone, code }) {
		return this.request({
			url: '/codelogin',
			method: 'POST',
			data: {
				phone,
				code,
				target: 1
			}
		});
	}

	// 修改用户信息
	update(params) {
		return this.request({
			url: '/update',
			method: 'POST',
			params: {
				...params
			}
		});
	}

	// 短信修改密码
	findpassword(params) {
		return this.request({
			url: '/findpassword',
			method: 'POST',
			params: {
				...params
			}
		});
	}

	// 绑定手机
	binding({ phone = '', code = '', password = '' }) {
		return this.request({
			url: '/binding',
			method: 'POST',
			data: {
				phone,
				code,
				password
			}
		});
	}
	// 合并账号
	merge({ phone }) {
		return this.request({
			url: '/merge',
			method: 'POST',
			data: {
				phone
			}
		});
	}
	// 退出
	logout() {
		return this.request({
			url: '/logout'
		});
	}
	getUserinfo(params = {}) {
		return this.request({
			url: '/userInfo',
			params
		});
	}
}
